package cn.star.jots.tag.controller;

import cn.star.jots.base.response.JsonResult;
import cn.star.jots.tag.pojo.dto.FilmTagQuery;
import cn.star.jots.tag.pojo.dto.TagSaveParam;
import cn.star.jots.tag.pojo.vo.FilmTagVO;
import cn.star.jots.tag.service.FIlmTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/tag")
@Api(tags = "标签管理")
@Slf4j
public class FilmTagController {

    @Autowired
    FIlmTagService filmTagService;

    @GetMapping("/select/{id}")
    @ApiOperation(value = "查询标签列表")
    public JsonResult select(@PathVariable Long id) {
        log.info("查询标签列表:id={}", id);
        List<FilmTagVO> list = filmTagService.selectAll(id);
        return JsonResult.ok(list);
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存标签")
    public JsonResult save(TagSaveParam tagSaveParam){
        log.info("保存标签:tagSaveParam={}", tagSaveParam);
        filmTagService.save(tagSaveParam);
        return JsonResult.ok();
    }

    @PutMapping("/update")
    @ApiOperation(value = "更新标签")
    public JsonResult update(TagSaveParam tagSaveParam){
        log.info("更新标签:tagSaveParam={}", tagSaveParam);
        filmTagService.update(tagSaveParam);
        return JsonResult.ok();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除标签")
    public JsonResult delete(@PathVariable Long id){
        log.info("删除标签:id={}", id);
        filmTagService.delete(id);
        return JsonResult.ok();
    }
}
